package com.example.nacosprovider.Config;

import com.example.nacosprovider.Listener.MyHttpSessionListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.SessionEventHttpSessionListenerAdapter;

import javax.servlet.http.HttpSessionListener;
import java.util.ArrayList;
import java.util.List;

/**
 * session配置类
 *
 */
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 120)
public class SpringSessionConfiguration {

    @Bean
    public SessionEventHttpSessionListenerAdapter sessionEventHttpSessionListenerAdapter()
    {
        List<HttpSessionListener> httpSessionListeners = new ArrayList<HttpSessionListener>();
        httpSessionListeners.add(new MyHttpSessionListener());
        return new SessionEventHttpSessionListenerAdapter(httpSessionListeners);
    }

}
